/**
 * 
 */
package com.curluin.controll;

import java.util.TimerTask;

/**
 * Extends TimerTask which can be given to Timer by Timer.schedule(TimerTask,...)
 * in order to be executed periodically
 * @author Alex
 *
 */
public class TimerAction extends TimerTask {
	
	/**
	 * Holds the controller in order to be able to trigger its methods
	 */
	private Controller controller;

	/** 
	 * Constructor
	 */
	public TimerAction(Controller controller) {
		this.controller = controller;
	}

	/**
	 * Method which will be executed by Timer
	 * @see java.util.TimerTask#run()
	 */
	@Override
	public void run() {
		
		controller.recomputeModel();
	}

	/* (non-Javadoc)
	 * @see java.util.TimerTask#cancel()
	 */
	@Override
	public boolean cancel() {
		controller = null;
		return super.cancel();
	}
	
	

}
